import http from '@/utils/request'
import { base } from '@/config'
const baseUrl = base.goods + '/goods'

// 商品信息模块
const goods = {
  // 查询基础标签列表数据
  delete: id => {
    return http.post(`${baseUrl}/delete/${id}`)
  },

  // 修改商品数据
  edit: data => {
    return http.postJson(`${baseUrl}/edit`, data)
  },

  // 通过商品ID获取二维码
  createQrcodeById: data => {
    return http.postJson(`${baseUrl}/createQrcodeById`, data)
  },

  // 修改启用平台
  enablePlatform: data => {
    return http.postJson(`${baseUrl}/enablePlatform`, data)
  },

  // 通过ID查询商品详情
  getById: params => {
    return http.get(`${baseUrl}/getById`, params)
  },

  // 查询商品列表数据
  page: parmas => {
    return http.get(`${baseUrl}/page`, parmas)
  },

  // 推荐（取消）商品至分类列表
  recommendCategory: (id, isRecommend) => {
    return http.post(`${baseUrl}/recommendCategory/${id}/${isRecommend}`)
  },

  // 推荐（取消）商品至首页
  recommendHome: (id, isRecommend) => {
    return http.post(`${baseUrl}/recommendHome/${id}/${isRecommend}`)
  },

  // 新增商品数据
  save: data => {
    return http.postJson(`${baseUrl}/save`, data)
  },

  // 指向商品列表
  getPoiontGoods: params => {
    return http.get(`${base.goods}/goods/referPage`, params)
  },

  // 导出至指定邮箱
  excelExport: params => {
    return http.get(`${base.goods}/goods/excelExport`, params)
  },

  // 批量修改上下架平台状态
  batchEnablePlatform: data => {
    return http.postJson(`${baseUrl}/batch/enablePlatform`, data)
  },

  //修改商品名称
  updateGoodsName: data => {
    return http.postJson(`${baseUrl}/enableGoodsName`, data)
  }
}

export default goods
